$(document).ready(function () {
    /**加载数据**/
    init_data()
    init_dept_distrue();
    init_dept_ec();
    init_dept_Iphone();
});
/**初始化数据**/
function init_data() {
    $.post(ctx+"customerIndex/indexCout",function (r) {
       if (r.code == 0){
        var data = r.msg;
        $("#AllbigEmp").text(data.allBigEmp);$("#AllbigEmpbar").css("width",data.bigCout+"%");$("#AllbigEmpCout").text(data.bigCout+"%");
        $("#AllYiGroup").text(data.AllYiGroup);$("#AllYiGroupbar").css("width",data.YiXiangCout+"%");$("#AllYiGroupCout").text(data.YiXiangCout+"%");
        $("#AllExEmp").text(data.AllExEmp);$("#AllExEmpbar").css("width",data.extCout+"%");$("#AllExEmpCout").text(data.extCout+"%");
        $("#AllSchool").text(data.AllSchool);$("#AllSchoolbar").css("width",data.schoolCout+"%");$("#AllSchoolCout").text(data.schoolCout+"%");
        $("#AllMyCustomer").text(data.AllMyCustomer);$("#AllMyCustomerbar").css("width",data.myCout+"%");$("#AllMyCustomerCout").text(data.myCout+"%");
        $("#AllGongSea").text(data.AllGongSea);$("#AllGongSeabar").css("width",data.GongSeaCout+"%");$("#AllGongSeaCout").text(data.GongSeaCout+"%");
       }else{
           $JuXue.n_danger("初始化资源统计数据失败");
       }
    });
    /**客户数据监控详情**/
    $.post(ctx+"customerIndex/indexCoutDetail",function (r) {
       if (r.code == 0){
            var data = r.msg;
            $("#bigempToday").text(data.AllBigToDay);$("#exempToday").text(data.AllExToDay);
           $("#schoDay").text(data.AllSchToday);$("#myCusToDay").text(data.AllMyCusday);
       }else{
           $JuXue.n_danger("初始化客户数据监控详情失败");
       }
    });
    /**消息提醒**/
    var url = ctx +"conversation/loadMyNotice";
    var count = "";
    $.post(url,{},function (r) {
        var data = r.data;
        count = data.length;
    });
}
/**初始化部门分配数量**/
function init_dept_distrue() {
    var myChart = echarts.init(document.getElementById('trainorder'));
    var option = {
        tooltip: {
            trigger: 'axis',
            axisPointer: {
                type: 'shadow'
            }
        },

        legend: {},
        grid: {
            left: '0%',
            right: '3%',
            bottom: '1%',
            top :'8%',
            containLabel: true
        },
        xAxis: {
            type: 'value',
            boundaryGap: [0, 0.01]
        },
        yAxis: {
            type: 'category',
            data: ['客服一部','客服二部','客服三部','客服四部','客服五部','客服六部','客服七部','客服八部']
        },
        series: [
            {
                name: '部门分配',
                type: 'bar',
                label: {
                    normal: {
                        show: true,
                        position: 'insideRight'
                    }
                },
                data: [182, 234, 290, 104, 131, 630,131, 630]
            }
        ]
    };
    myChart.setOption(option);
}
/**初始化有效通话**/
function init_dept_ec() {
    var myChart = echarts.init(document.getElementById('IponeConect'));

   var  option = {
        tooltip: {
            trigger: 'item',
            formatter: "{a} <br/>{b}: {c} ({d}%)"
        },
        legend: {
            orient: 'vertical',
            x: 'left',
            data:['有效通话','无效通话','接通电话','未接通电话']
        },
        series: [
            {
                name:'客户通话',
                type:'pie',
                selectedMode: 'single',
                radius: [0, '30%'],

                label: {
                    normal: {
                        position: 'inner'
                    }
                },
                labelLine: {
                    normal: {
                        show: false
                    }
                },
                data:[
                    {value:335, name:'有效通话', selected:true},
                    {value:679, name:'无效通话'},

                ]
            },
            {
                name:'客户通话',
                type:'pie',
                radius: ['40%', '55%'],

                data:[
                    {value:335, name:'接通电话'},
                    {value:310, name:'未接通电话'},
                ]
            }
        ]
    };
    myChart.setOption(option);
}

/**初始化部门电话沟通**/
function init_dept_Iphone() {

    var myChart = echarts.init(document.getElementById('IponeDeptConect'));
    var option = {
        tooltip: {
            trigger: 'axis',
            axisPointer: {
                type: 'shadow'
            }
        },

        legend: {},
        grid: {
            left: '0%',
            right: '3%',
            bottom: '1%',
            top :'8%',
            containLabel: true
        },
        xAxis: {
            type: 'value',
            boundaryGap: [0, 0.01]
        },
        yAxis: {
            type: 'category',
            data: ['客服一部','客服二部','客服三部','客服四部','客服五部','客服六部','客服七部','客服八部']
        },
        series: [
            {
                name: '部门分配',
                type: 'bar',
                label: {
                    normal: {
                        show: true,
                        position: 'insideRight'
                    }
                },
                data: [182, 234, 290, 104, 131, 630,131, 630]
            }
        ]
    };
    myChart.setOption(option);
}

